﻿using System;
using Microsoft.Phone.Controls;
using System.Collections.Generic;
using System.Windows;

namespace FlickrWP7
{
    public partial class Check : PhoneApplicationPage
    {
        public Check()
        {
            InitializeComponent();
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            //System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings["token"] = "0";
            //System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings["user"] = "0";
            //System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Save();
            try
            {
                if (System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings["token"].ToString() != "0")
                {
                    NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
                }
                else
                {
                    NavigationService.Navigate(new Uri("/AuthLocation.xaml", UriKind.Relative));
                }
            }
            catch (KeyNotFoundException)
            {
                System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Add("token", "0");
                System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings.Save();
                NavigationService.Navigate(new Uri("/AuthLocation.xaml", UriKind.Relative));
            }
        }
    }
}